Addd help and test fro stddev
authorJeroen van der Heijden <jeroen@transceptor.technology>
Thu, 17 May 2018 14:19:54 +0000 (16:19 +0200)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Thu, 17 May 2018 14:19:54 +0000 (16:19 +0200)
help/help_functions.md
test/test_select.py

index e89328aed47c105ca5b2908909b1a46a38d985b0..a14f2b7321d35f8bc1f9ae5fb6d991774ac6b24b 100644 (file)
@@ -159,6 +159,16 @@ Returns a float value.
 
 Returns the population variance of data, a non-empty iterable of real-valued numbers. Variance, or second moment about the mean, is a measure of the variability (spread or dispersion) of data. A large variance indicates that the data is spread out; a small variance indicates it is clustered closely around the mean.
 
+stddev
+------
+Syntax:
+
+    stddev([ts])
+
+Returns a float value.
+
+Returns the standard deviation which is the square root of its variance.
+
 difference
 ----------
 Syntax:
index ace99b756bcc3f48fc34c2459ad67907b903a9d2..994c3afb596d6a5755a8c7459da1e572165a31e8 100644 (file)
@@ -327,6 +327,20 @@ class TestSelect(TestBase):
                 DATA['aggr'][-1][0],
                 sum([x[1] for x in DATA['aggr']]) / len(DATA['aggr'])]]})
 
+        self.assertAlmostEqual(
+            await self.client0.query('select stddev() from "aggr"'),
+            {'aggr': [[
+                DATA['aggr'][-1][0],
+                147.07108914792838]]})
+
+        self.assertAlmostEqual(
+            await self.client0.query('select stddev(1h) from "aggr"'),
+            {"aggr": [
+                [1447250400, 1.8165902124584952],
+                [1447254000, 185.46409846162092],
+                [1447257600, 2.6457513110645907]]})
+
+
         # test prefix, suffex
         result = await self.client0.query(
                 'select sum(1d) prefix "sum-" suffix "-sum", '